<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <title>Agency - Responsive Flat Admin Dashboard</title>
    <meta content="Admin Dashboard" name="description" />
    <meta content="ThemeDesign" name="author" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <link rel="shortcut icon" href="${basePath}/admin/assets/images/faviicon.png">

    <link href="${basePath}/admin/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/admin/assets/css/icons.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/admin/assets/css/style.css" rel="stylesheet" type="text/css">

</head>


<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
    <div id="status">
        <div class="spinner"></div>
    </div>
</div>

<!-- Begin page -->
<div id="wrapper">

    <!-- ========== Left Sidebar Start ========== -->
    <div class="left side-menu">
        <button type="button" class="button-menu-mobile button-menu-mobile-topbar open-left waves-effect">
            <i class="ion-close"></i>
        </button>

        <!-- LOGO -->
        <div class="topbar-left">
            <div class="text-center">
                <!--<a href="index.html" class="logo">Admiry</a>-->
                <!-- <a href="index.html" class="logo">1<img src="${basePath}/admin/assets/images/logo.png" height="33" alt="logo"></a> -->
                <a href="index.html" class="logo">后台管理</a>
            </div>
        </div>

        <div class="sidebar-inner slimscrollleft">
            <div id="sidebar-menu">
                <ul>
                    <!-- <li class="menu-title text-white">General</li> -->

                        <li>
                            <a href="/admin/index" class="waves-effect">
                                <i class="ti-home"></i>
                                <span> 管理员管理 </span>
                            </a>
                        </li>
                        <li>
                            <a href="/category/admin/articleCategory" class="waves-effect">
                                <i class="ti-home"></i>
                                <span> 文章分类管理</span>
                            </a>
                        </li>
                        <li>
                            <a href="/article/admin/index" class="waves-effect">
                                <i class="ti-home"></i>
                                <span> 文章管理 </span>
                            </a>
                        </li>
                        <li>
                            <a href="/user/admin/index" class="waves-effect">
                                <i class="ti-home"></i>
                                <span> 用户管理 </span>
                            </a>
                        </li>
                        <li>
                            <a href="/comments/admin/index" class="waves-effect">
                                <i class="ti-home"></i>
                                <span> 评论管理 </span>
                            </a>
                        </li>
                        <li>
                            <a href="/message/admin/index" class="waves-effect">
                                <i class="ti-home"></i>
                                <span> 留言管理 </span>
                            </a>
                        </li>


                </ul>
            </div>
            <div class="clearfix"></div>
        </div>
        <!-- end sidebarinner -->
    </div>
    <!-- Left Sidebar End -->
    <div class="content-page">
        <!-- Start content -->
        <div class="content">

            <!-- Top Bar Start -->
            <div class="topbar">

                <nav class="navbar-custom">

                    <ul class="list-inline float-right mb-0">
                        <li class="list-inline-item dropdown notification-list">
                            <!-- 点击返回管理员表格(上一页) -->
                            <button class="btn btn-info btn-block waves-effect waves-light" type="submit" id="back" onclick="javascript:history.back(-1);">返回</button>
                        </li>
                        <li class="list-inline-item dropdown notification-list">
                            <a class="nav-link dropdown-toggle arrow-none waves-effect" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="false" aria-expanded="false">
                                <i class="mdi mdi-email-outline noti-icon"></i>
                                <span class="badge badge-danger noti-icon-badge">5</span>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right dropdown-arrow dropdown-menu-lg">
                                <!-- item-->
                                <div class="dropdown-item noti-title">
                                    <h5><span class="badge badge-danger float-right">745</span>Messages</h5>
                                </div>

                                <!-- item-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    <div class="notify-icon"><img src="${basePath}/admin/assets/images/users/avatar-2.jpg" alt="user-img" class="img-fluid rounded-circle" /> </div>
                                    <p class="notify-details"><b>Charles M. Jones</b><small class="text-muted">Dummy text of the printing and typesetting industry.</small></p>
                                </a>

                                <!-- item-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    <div class="notify-icon"><img src="${basePath}/admin/assets/images/users/avatar-3.jpg" alt="user-img" class="img-fluid rounded-circle" /> </div>
                                    <p class="notify-details"><b>Thomas J. Mimms</b><small class="text-muted">You have 87 unread messages</small></p>
                                </a>

                                <!-- item-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    <div class="notify-icon"><img src="${basePath}/admin/assets/images/users/avatar-4.jpg" alt="user-img" class="img-fluid rounded-circle" /> </div>
                                    <p class="notify-details"><b>Luis M. Konrad</b><small class="text-muted">It is a long established fact that a reader will</small></p>
                                </a>

                                <!-- All-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    View All
                                </a>

                            </div>
                        </li>

                        <li class="list-inline-item dropdown notification-list">
                            <a class="nav-link dropdown-toggle arrow-none waves-effect" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="false" aria-expanded="false">
                                <i class="mdi mdi-bell-outline noti-icon"></i>
                                <span class="badge badge-success noti-icon-badge">3</span>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right dropdown-arrow dropdown-menu-lg">
                                <!-- item-->
                                <div class="dropdown-item noti-title">
                                    <h5><span class="badge badge-danger float-right">87</span>Notification</h5>
                                </div>

                                <!-- item-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    <div class="notify-icon bg-primary"><i class="mdi mdi-cart-outline"></i></div>
                                    <p class="notify-details"><b>Your order is placed</b><small class="text-muted">Dummy text of the printing and typesetting industry.</small></p>
                                </a>

                                <!-- item-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    <div class="notify-icon bg-success"><i class="mdi mdi-message"></i></div>
                                    <p class="notify-details"><b>New Message received</b><small class="text-muted">You have 87 unread messages</small></p>
                                </a>

                                <!-- item-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    <div class="notify-icon bg-warning"><i class="mdi mdi-martini"></i></div>
                                    <p class="notify-details"><b>Your item is shipped</b><small class="text-muted">It is a long established fact that a reader will</small></p>
                                </a>

                                <!-- All-->
                                <a href="javascript:void(0);" class="dropdown-item notify-item">
                                    View All
                                </a>

                            </div>
                        </li>

                        <li class="list-inline-item dropdown notification-list">
                            <a class="nav-link dropdown-toggle arrow-none waves-effect nav-user" data-toggle="dropdown" href="#" role="button"
                               aria-haspopup="false" aria-expanded="false">
                                <img src="${basePath}/admin/assets/images/users/user-5.jpg" alt="user" class="rounded-circle">
                            </a>
                            <div class="dropdown-menu dropdown-menu-right profile-dropdown ">
                                <a class="dropdown-item" href="#"><i class="mdi mdi-account-circle m-r-5 text-muted"></i> Profile</a>
                                <a class="dropdown-item" href="#"><span class="badge badge-success pull-right">5</span><i class="mdi mdi-settings m-r-5 text-muted"></i> Settings</a>
                                <a class="dropdown-item" href="#"><i class="mdi mdi-lock-open-outline m-r-5 text-muted"></i> Lock screen</a>
                                <a class="dropdown-item" href="#"><i class="mdi mdi-logout m-r-5 text-muted"></i> Logout</a>
                            </div>
                        </li>

                    </ul>

                    <ul class="list-inline menu-left mb-0">
                        <li class="list-inline-item">
                            <button type="button" class="button-menu-mobile open-left waves-effect">
                                <i class="ion-navicon"></i>
                            </button>
                        </li>
                        <li class="hide-phone list-inline-item app-search">
                            <h3 class="page-title">Tables</h3>
                        </li>
                    </ul>

                    <div class="clearfix"></div>

                </nav>

            </div>
            <!-- Top Bar End -->

            <div class="page-content-wrapper ">

                <div class="container-fluid">


                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card m-b-30">
                                <div class="card">
                                    <div class="card-body">

                                        <h3 class="text-center mt-0 m-b-15">
                                            <a href="index.html" class="logo logo-admin"><img src="${basePath}/admin/assets/images/logo.png" height="30" alt="logo"></a>
                                        </h3>

                                        <h4 class="text-muted text-center font-18"><b>管理员信息修改</b></h4>

                                        <div class="p-3">
                                            <form class="form-horizontal m-t-20" id="adminChangeForm" action="../../admin/change" method="post">
                                                <input  type="hidden" name="adminId" id="adminId" value="${admin.adminId}"/>
                                                <div class="form-group row">
                                                    <div class="col-12">
                                                        <input class="form-control" type="text" id="adminName" name="adminName" placeholder="Username" value="${admin.adminName}">
                                                    </div>
                                                </div>
                                                <div class="form-group row">
                                                    <div class="col-12">
                                                        <input class="form-control" type="password" id="adminOldPassword" name="adminOldPassword" placeholder="old Password">
                                                    </div>
                                                </div>

                                                <div class="form-group row">
                                                    <div class="col-12">
                                                        <input class="form-control" type="password" id="adminNewPassword" name="adminNewPassword" placeholder="new Password">
                                                    </div>
                                                </div>

                                                <div class="form-group text-center row m-t-20">
                                                    <div class="col-12">
                                                        <button class="btn btn-info btn-block waves-effect waves-light" type="button" id="adminChange">确认修改</button>
                                                    </div>
                                                </div>

                                            </form>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div> <!-- end col -->
                    </div> <!-- end row -->

                </div><!-- container -->


            </div> <!-- Page content Wrapper -->

        </div> <!-- content -->

        <footer class="footer">
            © 2018 Upcube - Crafted with <i class="mdi mdi-heart text-danger"></i> by Themesdesign.
        </footer>

    </div>
    <!-- End Right content here -->
</div>


<!-- jQuery  -->
<script src="${basePath}/admin/assets/js/jquery-1.9.1.min.js"></script>
<script src="${basePath}/admin/assets/js/popper.min.js"></script>
<script src="${basePath}/admin/assets/js/bootstrap.min.js"></script>
<script src="${basePath}/admin/assets/js/modernizr.min.js"></script>
<script src="${basePath}/admin/assets/js/detect.js"></script>
<script src="${basePath}/admin/assets/js/fastclick.js"></script>
<script src="${basePath}/admin/assets/js/jquery.slimscroll.js"></script>
<script src="${basePath}/admin/assets/js/jquery.blockUI.js"></script>
<!-- <script src="${basePath}/admin/assets/js/waves.js"></script> -->
<script src="${basePath}/admin/assets/js/jquery.nicescroll.js"></script>
<script src="${basePath}/admin/assets/js/jquery.scrollTo.min.js"></script>

<!-- App js -->
<script src="${basePath}/admin/assets/js/app.js"></script>
<script type="text/javascript">

    $(function () {
        $('#adminChange').click(function () {
            var adminChangeForm = $('#adminChangeForm');

            var obj = {
                adminId: $('#adminId').val(),
                adminName: $('#adminName').val(),
                adminOldPassword: $('#adminOldPassword').val(),
                adminNewPassword: $('#adminNewPassword').val()
            };
            console.log(obj)
            var jsonSerialized = JSON.stringify(obj);
//            var jsonSerialized = obj;
            $.ajax({
                type: "POST",
                url: adminChangeForm.attr('action'),
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: jsonSerialized,
                success: function (result) {
                    if (result.success) {
                        alert(result.msg);
                        window.location.href="../../admin/index"
                    }else {
                        alert(result.msg);
                    }

                },
                error: function (error) {
                    alert("There was an error posting the data to the server: " + error.responseText);
                }
            });

        });

    });


    //
    //    function Tochange() {
    //
    //        $.ajax({
    //            url: '../../admin/change',//地址
    //            dataType: 'json',//数据类型
    //            data: $('#adminChangeForm').serialize(),
    //            type: 'post',//类型
    //            async: false,
    //            contentType: "application/x-www-form-urlencoded; charset=utf-8",
    //            timeout: 2000,//超时
    //            //请求成功
    //            success: function (data, status) {
    //                var result = eval("(" + data + ")");
    //                alert(result)
    //                console.log(result)
    //            },
    //            //失败/超时
    //            error: function (XMLHttpRequest, textStatus, errorThrown) {
    //                if (textStatus === 'timeout') {
    //                    alert('請求超時');
    //                    setTimeout(function () {
    //                        alert('重新请求');
    //                    }, 2000);
    //                }
    //            }
    //        })
    //
    //    }

</script>
</body>
</html>